package str;

import java.util.Iterator;
import java.util.Stack;

/**
 * @author:Administrator
 * @date:2022/1/18
 * @describe:
 */
public class StackTest {

    public static void main(String[] args) {

        Stack<String> stack = new Stack<>();
        System.out.println("===========>stack is empty: " + stack.isEmpty());
        stack.push("1");
        stack.push("2");
        stack.push("3");

        pressStack(stack);
        System.out.println("===========>stack size: " + stack.size());
        System.out.println("===========>stack top：" + stack.pop());
        System.out.println("===========>stack peek: " + stack.peek());
        pressStack(stack);

        System.out.println("===========>" + stack.search("one"));
    }

    /**
     * 压栈
     */
    public static void pressStack(Stack<String> s) {
        Iterator<String> it = s.iterator();
        while (it.hasNext()) {
            System.out.print("------>press stack：" + it.next() + "\n");
        }


    }
}


